package com.hjxr.sysadmin.zsj.controller;

import java.util.List;

import com.hjxr.framework.web.domain.AjaxResult;
import com.hjxr.sysadmin.uitl.poi.ExcelUtil;
import com.hjxr.sysadmin.web.controller.BaseController;
import com.hjxr.sysadmin.web.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hjxr.framework.aspectj.lang.annotation.Log;
import com.hjxr.framework.aspectj.lang.enums.BusinessType;
import com.hjxr.sysadmin.zsj.domain.ZonePolygon;
import com.hjxr.sysadmin.zsj.service.IZonePolygonService;

/**
 * 地块画图坐标Controller
 *
 * @author hjxr
 * @date 2021-03-31
 */
@Api("地块画图坐标Controller")
@RestController
@RequestMapping("/zonepolygon")
public class ZonePolygonController extends BaseController
{
    @Autowired
    private IZonePolygonService zonePolygonService;

    /**
     * 查询地块画图坐标列表
     */
//    @PreAuthorize("@ss.hasPermi('zsj:zonepolygon:list')")
    @ApiOperation(" 查询地块画图坐标列表")
    @GetMapping("/list")
    public TableDataInfo list(ZonePolygon zonePolygon)
    {
        startPage();
        List<ZonePolygon> list = zonePolygonService.selectZonePolygonList(zonePolygon);
        return getDataTable(list);
    }

    /**
     * 导出地块画图坐标列表
     */
//    @PreAuthorize("@ss.hasPermi('zsj:zonepolygon:export')")
    @Log(title = "地块画图坐标", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ZonePolygon zonePolygon)
    {
        List<ZonePolygon> list = zonePolygonService.selectZonePolygonList(zonePolygon);
        ExcelUtil<ZonePolygon> util = new ExcelUtil<ZonePolygon>(ZonePolygon.class);
        return util.exportExcel(list, "zonepolygon");
    }

    /**
     * 获取地块画图坐标详细信息
     */
//    @PreAuthorize("@ss.hasPermi('zsj:zonepolygon:query')")
    @GetMapping(value = "/{zonePolygonId}")
    public AjaxResult getInfo(@PathVariable("zonePolygonId") Long zonePolygonId)
    {
        return AjaxResult.success(zonePolygonService.selectZonePolygonById(zonePolygonId));
    }

    /**
     * 新增地块画图坐标
     */
//    @PreAuthorize("@ss.hasPermi('zsj:zonepolygon:add')")
    @Log(title = "地块画图坐标", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZonePolygon zonePolygon)
    {
        return toAjax(zonePolygonService.insertZonePolygon(zonePolygon));
    }

    /**
     * 修改地块画图坐标
     */
//    @PreAuthorize("@ss.hasPermi('zsj:zonepolygon:edit')")
    @Log(title = "地块画图坐标", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZonePolygon zonePolygon)
    {
        return toAjax(zonePolygonService.updateZonePolygon(zonePolygon));
    }

    /**
     * 删除地块画图坐标
     */
//    @PreAuthorize("@ss.hasPermi('zsj:zonepolygon:remove')")
    @Log(title = "地块画图坐标", businessType = BusinessType.DELETE)
	@DeleteMapping("/{zonePolygonIds}")
    public AjaxResult remove(@PathVariable Long[] zonePolygonIds)
    {
        return toAjax(zonePolygonService.deleteZonePolygonByIds(zonePolygonIds));
    }
}
